Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5117

Optimize the EXISTS sub-query by Metadata RowCount

    XMLWordPrintableJSON

Details

    Description

      As same as the UNIQUE sub-query, before we convert the sub-query to RelNode. we use the Metadata to optimize it.

      EXISTS sub-query, If the sub-query is guaranteed to produce at least one row, just return TRUE. If the sub-query is guaranteed to produce no row, just return FALSE.

      For example:

      select *
      from dept as d
      where EXISTS (select count(*) from emp e where d.deptno = e.deptno)

      We can optimize it to:

      EnumerableTableScan(table=[[scott, DEPT]])

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              nobigo xiong duan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h